home *** CD-ROM | disk | FTP | other *** search
- function eventUp()
- {
- posX = Math.floor(this._x / tileW);
- posY = Math.floor(this._y / tileH);
- posFloorY = posY + 1;
- posNextY = posY - 1;
- curTileVal = map[posY][posX];
- floorTileVal = map[posFloorY][posX];
- nextTileVal = map[posNextY][posX];
- nextFloorTileVal = map[posNextY + 1][posX];
- newY = this._y - spd;
- if(curTileVal >= 5 && nextTileVal >= 5)
- {
- this.art.gotoAndStop("up");
- this.myDir = "up";
- txCenter = posX * tileW + tileW / 2;
- this._x = txCenter;
- if(nextTileVal >= 5)
- {
- this._y = newY;
- }
- else
- {
- tyCenter = posY * tileW + tileW / 2;
- if(newY < tyCenter)
- {
- newY = tyCenter;
- }
- this._y = newY;
- }
- }
- }
- function eventDown()
- {
- posX = Math.floor(this._x / tileW);
- posY = Math.floor(this._y / tileH);
- posFloorY = posY + 1;
- posNextY = posY + 1;
- curTileVal = map[posY][posX];
- floorTileVal = map[posFloorY][posX];
- nextTileVal = map[posNextY][posX];
- nextFloorTileVal = map[posNextY + 1][posX];
- newY = this._y + spd;
- if(curTileVal >= 5)
- {
- txCenter = posX * tileW + tileW / 2;
- this._x = txCenter;
- if(nextTileVal >= 5)
- {
- this.art.gotoAndStop("down");
- this.myDir = "down";
- this._y = newY;
- }
- else
- {
- tyCenter = posY * tileW + tileW / 2;
- if(newY >= tyCenter)
- {
- newY = tyCenter;
- this._y = newY;
- }
- else
- {
- this.art.gotoAndStop("down");
- this._y = newY;
- }
- }
- }
- }
- function eventLeft()
- {
- posX = Math.floor(this._x / tileW);
- posY = Math.floor(this._y / tileH);
- posFloorY = posY + 1;
- posNextX = posX - 1;
- curTileVal = map[posY][posX];
- floorTileVal = map[posFloorY][posX];
- nextTileVal = map[posY][posNextX];
- nextFloorTileVal = map[posFloorY][posNextX];
- newX = this._x - spd;
- if(nextTileVal > 0)
- {
- this._x = newX;
- this.art.gotoAndStop("left");
- this.myDir = "left";
- tyCenter = posY * tileW + tileW / 2;
- this._y = tyCenter;
- }
- else
- {
- txCenter = posX * tileW + tileW / 2;
- if(newX < txCenter)
- {
- newX = txCenter;
- }
- this._x = newX;
- }
- }
- function eventRight()
- {
- posX = Math.floor(this._x / tileW);
- posY = Math.floor(this._y / tileH);
- posFloorY = posY + 1;
- posNextX = posX + 1;
- curTileVal = map[posY][posX];
- floorTileVal = map[posFloorY][posX];
- nextTileVal = map[posY][posNextX];
- nextFloorTileVal = map[posFloorY][posNextX];
- newX = this._x + spd;
- if(nextTileVal > 0)
- {
- this._x = newX;
- tyCenter = posY * tileW + tileW / 2;
- this._y = tyCenter;
- this.art.gotoAndStop("right");
- this.myDir = "right";
- }
- else
- {
- txCenter = posX * tileW + tileW / 2;
- if(newX > txCenter)
- {
- newX = txCenter;
- }
- this._x = newX;
- }
- }
- function eventFire()
- {
- if(scripts.gameOn)
- {
- posX = Math.floor(this._x / tileW);
- posY = Math.floor(this._y / tileH);
- scripts.fireMustard();
- }
- }
- map = scripts.map;
- tileW = 30;
- tileH = 30;
- cTile = tileW / 2;
- var hTile = tileW / 2;
- var spd = 5;
-